<div class="bjui-pageHeader">
    <!-- 顶部模块[如：功能按钮、搜索面板] -->
    <div class="bjui-row col-md-11">
        <button type="button" class="btn-green pull-right" onclick="addUserInfo()">新增</button>
    </div>
</div>
<div class="bjui-pageContent">
    <!-- 内容区 -->
    <table id="userTable"></table>
    <script>
        var user = {
          userData:{}
        };
        $('#userTable').datagrid({
            dataUrl: URL+'findPageSmUser.do',
            filterThead:false,
            fieldSortable:false,
            height:'90%',
            columns: [
                {name:'userId',label:'ID',width:300},
                {name: 'userName', label: '姓名',align:'center',width:300},
                {name: 'userSex', label: '性别', align: 'center',width:300,render:function(value, data){if(data.userSex == 1){
                        return '男';
                    }else if(data.userSex == 0){
                    return'女'
                    }else {
                    return;
                    }}},
                {name: 'userAge', label: '年龄',align:'center',width:300},
                {name: 'userMobile', label: '联系方式', align: 'center',width:300},
                {name:'fp',label:'操作',align:'center',width:500,
                    render:function(value, data){return "<a class='operation-btn operation-btn-normal'onclick='update("+JSON.stringify(data)+")'>修改</a>" +
                        "<a class='operation-btn operation-btn-del' onclick='del("+JSON.stringify(data)+")'>删除</a>"}}
            ]
        })



        function addUserInfo() {
            BJUI.dialog({
                id:'add',
                url:'html/hospital/addUser.html',
                title:'新增用户'
            })

        }

        function update(data) {
            user.userData = data;
            BJUI.dialog({
                id:'update',
                url:'html/hospital/updateUser.html',
                title:'修改用户信息'
            })
        }

        function del(data) {
            BJUI.ajax('doajax', {
                url: URL+'deleteSmUserById.do',
                data:{
                    userId:data.userId,
                },
                loadingmask: true,
                okCallback: function(json, options) {
                    //刷新表格
                    $('#userTable').datagrid('refresh');
                }
            });
        }
    </script>
</div>
